<?php
/**
 * 生成二维码测试
 * 作者：刘单风
 * 最后修改时间：2018-11-14
 * 版权：医库PHP小组
 */
namespace app\api\controller;

use app\model\Luckprizes;
use MoCommon\Services\HttpBase;
use MoCommon\Support\Codes;
use think\Db;

class Ldfcodetest
{


    public function code()
    {
        $appid   = "wx20aed80859aeab40";
        $secret  = "6b6c608f96e03476244f9f758b3b92e4";
        //获取token
        $url="https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=$appid&secret=$secret";
        $access_token=HttpBase::curlapi($url,null,0,0);
        $access_token=json_decode($access_token,true);
        $access_token=$access_token['access_token'];

        //ticket;获取
        $url="https://api.weixin.qq.com/cgi-bin/qrcode/create?access_token=$access_token";
        $reqdata='{"action_name": "QR_LIMIT_STR_SCENE", "action_info": {"scene": {"scene_str": "yk_haosen"}}}';
        $ticket=HttpBase::curlapi($url,$reqdata,0,1);
        $ticket=json_decode($ticket,true);
        $ticket=$ticket['ticket'];
        echo "<script>window.location.href='https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=$ticket';</script>";
        exit;

    }

    public function emojitest()
    {
        exit;

    }
}